package com.iwuyc.fastexcel.ext.util

import org.junit.jupiter.api.Assertions.*

class ExcelUtilsTest {
    @org.junit.jupiter.api.Test
    fun rowIndexToAlpha() {
        assertEquals("A", ExcelUtils.rowIndexToAlpha(1))
        assertEquals("B", ExcelUtils.rowIndexToAlpha(2))
        assertEquals("Z", ExcelUtils.rowIndexToAlpha(26))
        assertEquals("AA", ExcelUtils.rowIndexToAlpha(27))
        assertEquals("AB", ExcelUtils.rowIndexToAlpha(28))
        assertEquals("BA", ExcelUtils.rowIndexToAlpha(53))
        assertEquals("ZZ", ExcelUtils.rowIndexToAlpha(702))
        assertEquals("AAA", ExcelUtils.rowIndexToAlpha(703))
        assertEquals("AAB", ExcelUtils.rowIndexToAlpha(704))
    }
    
    @org.junit.jupiter.api.Test
    fun alphaToRowIndex() {
        assertEquals(1, ExcelUtils.alphaToRowIndex("A"))
        assertEquals(2, ExcelUtils.alphaToRowIndex("B"))
        assertEquals(26, ExcelUtils.alphaToRowIndex("Z"))
        assertEquals(27, ExcelUtils.alphaToRowIndex("AA"))
        assertEquals(28, ExcelUtils.alphaToRowIndex("AB"))
        assertEquals(53, ExcelUtils.alphaToRowIndex("BA"))
        assertEquals(702, ExcelUtils.alphaToRowIndex("ZZ"))
        assertEquals(703, ExcelUtils.alphaToRowIndex("AAA"))
        assertEquals(704, ExcelUtils.alphaToRowIndex("AAB"))
        assertEquals(1379, ExcelUtils.alphaToRowIndex("BAA"))
        
        // 测试小写字母
        assertEquals(1, ExcelUtils.alphaToRowIndex("a"))
        assertEquals(27, ExcelUtils.alphaToRowIndex("aa"))
        
        // 测试混合大小写
        assertEquals(27, ExcelUtils.alphaToRowIndex("Aa"))
        assertEquals(27, ExcelUtils.alphaToRowIndex("aA"))
    }
}